<?php
error_reporting(0);
$matches=parse_url($_SERVER['HTTP_REFERER']);
define('MCC_ROOT',dirname(__FILE__));

require_once MCC_ROOT.'/include/global.inc.php';

$action=$_POST['action'];
$ip=$_POST['ip'];
$port=$_POST['port'];
$username=$_POST['username'];
$pwd=$_POST['pwd'];
$dbname=$_POST['dbname'];
if('edit'==$action){
	$dsdbhost = $ip.":".$port;			// DS数据库服务器
	$dsdbuser = $username;			// DS数据库用户名
	$dsdbpw = $pwd;				// DS数据库密码
	$dsdbname = $dbname;			// DS数据库名
	//重写配置文件，并且删除缓存种子文件
		$filename="include/mysql_info.php";
		$fp=fopen($filename,'wb+');
		if($fp)
		{
			$str="<?php\n\$dsdbhost = '".$dsdbhost."';\n \$dsdbuser = '".$dsdbuser."';\n \$dsdbpw = '".$dsdbpw."';\n \$dsdbname = '".$dsdbname."';\n?>";		
			fwrite($fp,$str);
			fclose($fp);
		adminmsg('操作成功！','change_mysql.php');
		}else
		adminmsg('路径错误！','change_mysql.php');
}elseif('oedit'==$action){
	echo "还原";
}
?>